package com.whut.work.course.service.impl;

import com.whut.work.base.model.Page;
import com.whut.work.course.dao.impl.CourseDaoImpl;
import com.whut.work.course.model.Course;
import com.whut.work.course.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by zouyao on 2017/3/15.
 */
@Component
public class CourseServiceImpl implements ICourseService {

    @Autowired
    private CourseDaoImpl courseDao;

    public Page<Course> getCoursePageListByUserId(int currentPage, int pageSize, Integer userId) throws Exception {
        String queryHql = "from Course c where c.user.id='"+userId+"' ";
        String countHql = "select count(*) from Course c where c.user.id='"+userId+"' ";
        Page<Course> returnPage = courseDao.findPage(currentPage, pageSize, queryHql, countHql);

        return returnPage;
    }

}
